/**
 * Created by 45865 on 2020/5/23.
 */
/**
 * 修改页面初始显示当前用户的信息
 */
function show() {
    // $('input[name="user"]').val("dannel");
    // var loginName = $('input[name="user"]').val()
    // console.log(loginName)
    $.ajax({
        url:"/personal/select",
        //data:{loginName:loginName},
        //data:"",
        dataType:"json",
        type:"post",
        //contentType: "application/json",
        success:function (data) {
            console.log(data)
            $('input[name="realname"]').val(data.customerName);
            $('input[name="birthday"]').val(data.customerBirthday);
            $('input[name="sex"]').val(data.customerSex);
            $('input[name="phone"]').val(data.customerPhone);
        }
    })
}
show()

/**
 * 在对应的位置进行修改
 */
function submitUpdate() {
    // $('input[name="user"]').val("dannel");
    // var loginName = $('input[name="user"]').val()
    var customerName = $('input[name="realname"]').val()
    var customerBirthday = $('input[name="birthday"]').val()
    var customerSex = $('input[name="sex"]').val()

    //var params = "loginName:"+loginName+"&customerName:"+customerName+"&customerBirthday:"+customerBirthday+"&customerSex:"+customerSex
    //alert("{loginName:"+loginName+",customerName:"+customerName+",customerBirthday:"+customerBirthday+",customerSex:"+customerSex+",}")

    //var date = new Date();
    var updateInfo = {
        //loginName:loginName,
        customerName:customerName,
        customerBirthday: customerBirthday,
        customerSex:customerSex
    }
    //console.log(updateInfo)
    $.ajax({
        url: "/personal/update",
        contentType: "application/json",
        data:JSON.stringify(updateInfo),
        //data:updateInfo,
        //dataType:"json",
        type:"post",
        success: function (data) {
            if (data == "success"){
                    alert("修改成功")
                }

            }

    })
    // $.ajax({
    //     url: "/personal/update",
    //     contentType: "application/json; charset=utf-8",
    //     //data:JSON.stringify(updateInfo),
    //     data:params,
    //     dataType: "json",
    //     type: "post",
    //     success: function (data) {
    //         console.log(data)
    //
    //         if (data == 1){
    //             alert("修改成功")
    //         }
    //
    //     }
    // })

    // JSON.stringify()
}


